home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / pre_view.zip / README.TXT < prev    next >
Text File  |  1995-10-30  |  7KB  |  141 lines

  1. ReadMe.txt file from Preview.Zip
  2.  
  3. Author: Brad Tharalson, CIS 72030,3045
  4.  
  5. Create a new directory, install using:  pkunzip -d preview.
  6. If you don't use the '-d' option, all
  7. the files end up in the same directory
  8. and it will need to be re-installed.
  9.  
  10. PrnInit.txt  Contains list of printers and Queues they can attach to.
  11.              Loaded during StartLinePrinter().  If your printer is not on
  12.              the list, the program should still work correctly.
  13.  
  14. In the main install directory is the project file (PrnPrev.dpr) that shows
  15. the use of the wPreview unit.  Open the project, ignore the message, if any,
  16. that says: Error Reading Symbol File.  Build and Run the program.
  17.  
  18. It starts with a Select Printer form, if your current printer is not shown
  19. then please select it.  Make sure the "Preview Reports Before Printing"
  20. checkbox is selected.
  21.  
  22. Under the "Preview Samples" menu choice, select any choice, these consist
  23. of several prepared command list files that are then "Played Back", more
  24. later. When on the Preview form, you can use the popup menu attached to the
  25. right button to select the choices at the top of the Preview form if they
  26. should scroll off the forms canvas.
  27.  
  28. For the "View Blue Print" selection, there are two bitmaps involved.  The full
  29. size image is 2200x1700 (470k), the "Select" image is only 613x337.  The
  30. "Select" image appears first, click anywhere on this image and wait
  31. a few seconds, the appropriate area on the full image will come into view.
  32. You can then use "Up","Down", etc., buttons to move around the image or if
  33. you click on the full image the "Select" image reappears and you can select
  34. a new area to view, in essence, hop back and forth.
  35.  
  36. Before you try the "Print Blue Print" test, make sure your printer resolution
  37. is less than or equal to 300 DPI.  I've had problems with higher resolutions.
  38.  
  39. wPreview Unit Concept
  40. ---------------------
  41.  
  42. I tried to find a unit I could use to give my software the same "Print With
  43. Preview" capability found in commercial packages.  Unfortunately I couldn't
  44. find something to fit my needs.
  45.  
  46. Printing is very easy in Delphi using their supplied Printers unit.  For
  47. years my end-users have been use to being able to view plain text reports
  48. on the screen before printing.  First, I wrote the routine to send each
  49. canvas page to the screen or printer as they have chosen.  Of course, they
  50. wanted to be able to hop around among different pages.
  51.  
  52. So I decided that I would capture all of parameters passed into the routines
  53. I already use for printing. Search for AddCommand() lines in wPreview.pas.
  54. If they wanted it to go directly to the printer the parameters are not saved,
  55. and the commands are immediately processed.
  56.  
  57. Each group of routines for a page are kept separate in their own TStringList
  58. object, at any time a single page or all pages can be passed to the
  59. PlayBackPage routine and it will clear the current drawing canvas and
  60. process the commands in the TStringList in the same order they were created.
  61.  
  62. These TStringList objects can also be saved to a file for later playback,
  63. see the SaveCommands and PrintCommandFile routines.  Most of the sample
  64. choices are just command files that are being played back, these were
  65. generated using our Job Costing system. The saving occured in the PlayBackPage
  66. routine, search for SaveCommands(), you'll see where I commented it out.
  67.  
  68. I have included the Delphi code used to generate the Command files that are
  69. played back on the sample menu. Search for "StartDoc" in the files below:
  70.  
  71. Command File         Menu Choice
  72. ------------         -----------
  73. DemoRout.txt      Preview Routing Card,  see Samples/RoutCard.pas
  74. DemoJob.txt       Preview Job Cost,      see Samples/JBdet.pas
  75. DemoInfo.txt      Preview Job Due/Ship,  see Samples/JCcommon.pas
  76.  
  77. Printing sequence follow:
  78.  
  79.   1.  Use "Select Printer" menu choice under "File" menu to set the print
  80.       destination and whether to preview reports before printing.
  81.   2.  Create "Lpr" object, use its methods to create your print file.
  82.   3.  "TPreview" form (Minimized) is created whether you want Report
  83.       Preview or not.  This is nice because you will see icons showing
  84.       all the reports you are currently formatting.
  85.   4.  When you end your series of print commands with StopDoc(), one of two
  86.       things will happen:
  87.         a. Preview Selected: TPreview form is Maximized, first page appears.
  88.            TPreview form stays open until you close it.
  89.  
  90.            Lpr --> Commands List --> TPreview form created -->
  91.              Lpr (destroyed) --> TPreview uses its own Lpr object to
  92.                                  view and/or print pages as needed.
  93.  
  94.         b. No Preview Selected: TPreview form is removed after printing.
  95.  
  96.            Lpr --> Direct To Printer --> Lpr (destroyed)
  97.  
  98. Code Sample:   Print Customer Names List (simplified)
  99. -----------
  100.  
  101.     procedure CustLIst;
  102.     var lpp:Lpr;  { Lpr is in unit wPreview.pas }
  103.         tdb:oDB:  { from DBserver.pas unit in Clp2Dlfi directory }
  104.     begin
  105.       lpp:=Lpr.create;
  106.       tdb:=nil;
  107.       dbUse(tdb,'cust');  { open Cust.dbf }
  108.       with lpp do begin
  109.         SetDestination;
  110.         StartDoc(for8x11,'Customer List');
  111.         while not tdb.eof do begin
  112.           { have to use "lpp.writeln" because WriteLn is built-in to Delphi,
  113.             and it takes precedence if no qualifier }
  114.           lpp.writeln(tdb.s('cust')+'  ('+tdb.s('cust_no')+')');
  115.         end;
  116.         StopDoc;
  117.       end;
  118.       dbClose(tdb);
  119.       lpp.free;
  120.     end;
  121.  
  122. SetDestination should only be called once just before starting a series
  123. of StartDoc-StopDoc sequences.  You can use the wPreview.pas unit to
  124. print several reports at the same time, some you may have wanted
  125. to preview when done, others you may be sending to one or more different
  126. printers.
  127.  
  128. Note: there is no BTPrint.pas file for the BTPrint.dcu file.  I was having
  129.       some problems with the GetCanvas routine in Printers.pas in the VCL.
  130.       So I moved the FCanvas declaration to the public section and set it to
  131.       Nil in the TPrinterCanvas.Create routine.  I don't think I can give you
  132.       this changed code because it's Borland's.  But I think I can give you
  133.       the compiled unit which is all that is really necessary.  If you
  134.       accidently remove the BTPrint.dcu unit, you can copy BTPrint.ucd to
  135.       BTPrint.dcu.
  136.  
  137. Hope the samples and the wPreview.pas routines can save you some time.
  138.  
  139. Brad Tharalson
  140. 72030,3045
  141.